package com.ydc.controller;

import com.ydc.pojo.Admin;
import com.ydc.service.AdminService;
import com.ydc.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @PostMapping("/login")
    public SysResult login(@RequestBody Admin admin){


        String token = adminService.selectAdmin(admin);
        if(StringUtils.hasLength(token))
            return SysResult.success(token);
        return SysResult.fail();
    }
}
